<html>
<head>
    <title>登录</title>
    <meta charset="utf-8" name="decorator" content="default"/>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <style>
        * {
            margin: 0 auto;
        }

        body {
            background-color: #343a40;
        }

        .container {
            position: relative;
            top: 100px;
        }

        .news-nav {
            clear: both;
            height: 80px;
            margin-left: 10px;
            margin-right: 10px;
            width: 300px;
            margin: 0 auto;
        }

        .news-nav li {
            float: left;
            list-style-type: none;
            margin: 0 10px;
            font-size: 30px;
            display: block;
            width: 86px;
            height: 79px;
            text-align: center;
            line-height: 79px;
            font-weight: bold;
            color: #007bff;
            cursor: pointer;
        }

        .news-nav li.on {
            color: #74dcff;
            border-bottom-color: #74dcff;
            border-bottom-style: solid;
            border-bottom-width: 2px;
        }

        #index-news-list-2 {
            display: none;
        }

        .modal-dialog {
            max-width: 100% !important;
        }

        .modal-content {
            background: rgba(0, 0, 0, 0.3);
            width: 700px;
        }

        .loginForm {
            width: 400px;
        }

        .loginForm .form-group {
            margin: 30px 0;
        }

        .loginForm .form-group .form-control {
            height: 40px;
            font-size: 15px;
        }

        input[type="checkbox"] {
            position: relative;
            top: -2px;
            vertical-align: middle;
            cursor: pointer;
            zoom: 1.6;
        }

        input[type="radio"] {
            position: relative;
            top: -3px;
            vertical-align: middle;
            cursor: pointer;
            zoom: 1.6;
        }

        .btn-primary {
            background-color: #3e4963;
            border: 0px solid transparent;
            width: 400px;
            height: 50px;
            font-size: 24px;
            font-family: STKaiti;
        }

        label {
            color: #fff;
            font-size: 16px;
        }
    </style>
</head>
<body>
<div class="container">
    <div class="modal-dialog" id="login_form">
        <div class="modal-content">
            <div class="modal-title">
                <ul class="news-nav js-nav-title">
                    <li class="on" data="login">登录</li>
                    <li class="" data="register">注册</li>
                </ul>
            </div>
            <div class="modal-body index-news-list" id="index-news-list-1">
                <form class="loginForm" id="loginForm" action="" method="post">
                    <div class="form-group">
                        <input class="form-control required" name="name" id="name" type="text" placeholder="请输入学号">
                    </div>
                    <div class="form-group">
                        <input class="form-control required" name="password" id="password" type="password"
                               placeholder="请输入密码">
                    </div>

                    <div class="form-group">
                        <button id = 'login' class="btn btn-primary" type="button">登录</button>
                    </div>
                </form>
            </div>

            <div class="modal-body index-news-list" id="index-news-list-2">
                <form class="loginForm" id="registerForm" action="" method="post">
                    <div class="form-group">
                        <input class="form-control required" name="name" id="regist_name" type="text"
                               placeholder="请输入学号">
                    </div>
                    <div class="form-group">
                        <input class="form-control required" name="password" id="regist_Password" type="password"
                               placeholder="请输入密码">
                    </div>

                    <div class="form-group">
                        <button class="btn btn-primary" type="submit" id = 'regist'>注册</button>
                    </div>
                </form>
            </div>

        </div>
    </div>
</div>
<script>
    $(document).ready(function () {
        $(".js-nav-title li").click(function () {
            $(this).attr("class", "on");
            $(this).siblings().attr("class", "");
            var index = $(".js-nav-title li").index(this);
            $(".index-news-list").css("display", "none");
            $("#index-news-list-" + (index + 1)).css("display", "block");
        });
    });


    $("#login").click(function () {
        $.ajax({
            url: "/login",
            type: "POST",
            dataType: 'json',
            data: {
                User: $("#name").val(),
                Password: $("#password").val()
            },
            success: function (result) {
                alert(result)
                if(result == 'cg'){
                    window.open('/index','_self')
                }

            },
            error: function () {
                console.log('shibai')

            },
        });
    })


    $("#regist").click(function() {
        $.ajax({
            url: "/regist",
            type: "POST",
            dataType: 'json',
            data: {
                User: $("#regist_name").val(),
                Password: $("#regist_Password").val()
            },
            success: function (result) {
                alert(result)
                console.log(result)},
            error: function(){
                console.log('shibai')

            },
        });
    })


</script>
</body>
</html>
